package com.xiang.atomikos.service.impl;

import com.xiang.atomikos.entity.UserEntity;
import com.xiang.atomikos.service.AddUserOneService;
import com.xiang.atomikos.service.AddUserTwoService;
import com.xiang.atomikos.service.UserEntityTestService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserEntityTestServiceImpl implements UserEntityTestService {

  @Resource
  AddUserOneService oneService;

  @Resource
  AddUserTwoService twoService;


  @Override
  @Transactional(rollbackFor = RuntimeException.class)
  public int save(UserEntity userBakEntity) {

    oneService.saveOne(userBakEntity);
    int a= 1/0;
    twoService.saveTwo(userBakEntity);

    return 1;
  }
}
